package com.reremouse.rerebbs.web.mb.mag;

import com.reremouse.rerebbs.dao.IBbsUserDAO;
import com.reremouse.rerebbs.dao.ISystemConfigDAO;
import com.reremouse.rerebbs.model.BbsUser;
import com.reremouse.util.JsfHelper;
import com.reremouse.util.SpringHelper;

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@ManagedBean
@ViewScoped
public class ViewClientUser
        implements Serializable {
    IBbsUserDAO BbsUserDAO = (IBbsUserDAO) SpringHelper.getSpringBean("BbsUserDAO");
    ISystemConfigDAO scDAO = (ISystemConfigDAO) SpringHelper.getSpringBean("SystemConfigDAO");
    HttpServletRequest request = JsfHelper.getRequest();
    BbsUser cu;
    List<SelectItem> depts = new ArrayList();
    List<SelectItem> uts = new ArrayList();

    public BbsUser getCu() {
        return this.cu;
    }

    public void setCu(BbsUser cu) {
        this.cu = cu;
    }

    public List<SelectItem> getDepts() {
        return this.depts;
    }

    public void setDepts(List<SelectItem> depts) {
        this.depts = depts;
    }

    public List<SelectItem> getUts() {
        return this.uts;
    }

    public void setUts(List<SelectItem> uts) {
        this.uts = uts;
    }

    @PostConstruct
    public void init() {
        String idt = this.request.getParameter("id");
        if (idt != null) {
            long id = Long.parseLong(idt);
            this.cu = this.BbsUserDAO.findBbsUser(id);
        }
    }

    public String initPwd() {
        String pwd = this.scDAO.getSystemConfig().getInitPwd();
        this.cu.setPassword(pwd);
        this.BbsUserDAO.updateBbsUser(this.cu);
        FacesMessage fm = new FacesMessage();
        fm.setSeverity(FacesMessage.SEVERITY_INFO);
        fm.setSummary("初始化密码完成！");
        FacesContext.getCurrentInstance().addMessage("", fm);
        return null;
    }

    public String finish() {
        System.out.println("当前密码是：" + this.cu.getPassword());
        this.BbsUserDAO.updateBbsUser(this.cu);
        return "ListClientUser?faces-redirect=true";
    }
}



/* Location:           F:\jsp源码\蝙蝠论坛系统\rerebbs\WEB-INF\classes\

 * Qualified Name:     com.reremouse.rerebbs.web.mb.mag.ViewClientUser

 * JD-Core Version:    0.7.0.1

 */